/**
 * 
 */
package soa.security.domain;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

/**
 * @author Cre.Gu
 *
 */
public class LdapTree implements Serializable {

	private static final long serialVersionUID = -188984181050265215L;

	private String id;
	private String bid;
	private String text;
	private boolean isLeaf;
	private String organizationId;
	private boolean checked;
	private boolean expanded;
	private String regionLevel;

	private Region region;
	private Organization organization;
	private Department department;

	private Class<?> currentClazz;

	public LdapTree() {
	}

	public LdapTree(String id, String bid, String text) {
		super();
		this.id = id;
		this.bid = bid;
		this.text = text;
	}

	public LdapTree(String id, String bid, String text, Class<?> currentClazz) {
		super();
		this.id = id;
		this.bid = bid;
		this.text = text;
		this.currentClazz = currentClazz;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getBid() {
		return bid;
	}

	public void setBid(String bid) {
		this.bid = bid;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public boolean isLeaf() {
		return isLeaf;
	}

	public void setLeaf(boolean isLeaf) {
		this.isLeaf = isLeaf;
	}

	public Region getRegion() {
		return region;
	}

	public void setRegion(Region region) {
		this.region = region;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public Class<?> getCurrentClazz() {
		return currentClazz;
	}

	public String getClassName() {
		if (currentClazz != null)
			return currentClazz.getName();
		return null;
	}

	public String getType() {
		if (currentClazz != null)
			return currentClazz.getSimpleName();
		return null;
	}

	public String getIconCls() {
		return "icon-" + StringUtils.lowerCase(getType());
	}

	public boolean isExpanded() {
		return expanded;
	}

	public void setExpanded(boolean expanded) {
		this.expanded = expanded;
	}

	public void setCurrentClazz(Class<?> currentClazz) {
		this.currentClazz = currentClazz;
	}

	public String getOrganizationId() {
		return organizationId;
	}

	public void setOrganizationId(String organizationId) {
		this.organizationId = organizationId;
	}

	public boolean isChecked() {
		return checked;
	}

	public String getRegionLevel() {
		return regionLevel;
	}

	public void setRegionLevel(String regionLevel) {
		this.regionLevel = regionLevel;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public boolean hasParent() {
		return getRegion() != null || getOrganization() != null
				|| getDepartment() != null;
	}
}
